package com.lagou.stage1.model4.controller;

import com.github.pagehelper.PageInfo;
import com.lagou.stage1.model4.service.IArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * 文章接口层
 * @author 陶肖寅
 * @version V1.0
 * @Package com.lagou.stage1.model4.controller
 * @date 2020-02-19 17:40
 * @Copyright © 2020-2021 城云科技(中国)有限公司
 */
@Controller
@RequestMapping("/articles")
public class ArticleController {
    @Autowired
    IArticleService articleService;
    @GetMapping
    public String getArticlesPage(Model model,
                                  @RequestParam(name = "pageNum",defaultValue = "0")
                                  Integer pageNum,
                                  @RequestParam(name = "pageSize",defaultValue = "2")
                                  Integer pageSize) {
        PageInfo pageInfo =  articleService.getArticlePaged(pageNum,pageSize);
        model.addAttribute("page",pageInfo);
        return "client/index";
    }
}
